package twitpic.api.data
{
	public class TwitpicResponse
	{

		public static const STATUS_OK = "ok";
		public static const STATUS_FILE = "fail";
		public var status:String = null;
		public var statusid:Number;
		public var userid:Number;
		public var mediaid:String = null;
		public var mediaurl:String = null;
		public var errorCode:Number;
		public var msg:String = null;


		public function TwitpicResponse(res:Object) {
			var mediaidXML:XMLList = XML(res).child("mediaid");
			var mediaurlXML:XMLList = XML(res).child("mediaurl");
			var statusidXML:XMLList = XML(res).child("statusid");
			var useridXML:XMLList = XML(res).child("userid");

			status = res.attributes()[0];
			if (status==STATUS_OK) {
				statusid = statusidXML[0];
				userid = useridXML[0];
				mediaid = mediaidXML[0];
				mediaurl = mediaurlXML[0];
			} else {
				errorCode = XML(res).child("err").attributes()[0];
				msg = XML(res).child("err").attributes()[1];
			}
		}
	}
}